# coding: utf-8
from sqlalchemy import BigInteger, Column, DateTime, Integer, String
from sqlalchemy.schema import FetchedValue
from flask_sqlalchemy import SQLAlchemy
from common.models.Shop import Shop

from application import db
class TableItem(db.Model):
    __tablename__ = 'table_item'
    __table_args__ = {'schema': 'food_db'}

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False, server_default=db.FetchedValue())
    updated_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
    created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
    shop_id = db.Column(db.ForeignKey('food_db.shop.id'), nullable=False, index=True)

    shop = db.relationship('Shop', primaryjoin='TableItem.shop_id == Shop.id', backref='table_items')